package service;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import util.Base64Util;


public class VadeMecumMultimediaServiceClient {
	
	private static byte[] fileByteArray;
	
	private static String fileName;
	
	public VadeMecumMultimediaServiceClient(byte[] fileByteArray, String fileName) {
		this.fileByteArray = fileByteArray;
		this.fileName = fileName;
	}
	
    public static void main(String[] args) {
        VadeMecumMultimediaServiceStub stub;
        try {
            stub = new VadeMecumMultimediaServiceStub("http://localhost:8080/axis2/services/VadeMecumMultimediaService");
            VadeMecumMultimediaServiceStub.GetFile getFileStub = new VadeMecumMultimediaServiceStub.GetFile();
            getFileStub.setId(6);
            VadeMecumMultimediaServiceStub.GetFileResponse response = stub.getFile(getFileStub);
            
    		String fileURL = "/tmpVadeMecum/teste/testando.jpg"; 
    		File toSave = new File(fileURL);
    		try {
    			FileOutputStream foe = new FileOutputStream(toSave);
    			foe.write(Base64Util.decode(response.get_return()));
    			foe.close();
    			System.out.println("salvou");
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
            
//            VadeMecumMultimedia test = VadeMecumMultimediaDAO.getInstance().getThis(6);
//            System.out.println(test.getmetadata());
//            
//            VadeMecumMultimediaServiceStub.TestResponse res = stub.test(test);  
//            System.out.println("Web service invoked: " + res.get_return());
       } catch (Exception e) {
           e.printStackTrace();
       }
    }

}
